
<!DOCTYPE html>
<html lang="en" class="no-js">

<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="description" content="">
	<meta name="keywords" content="">
	<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
	<link rel="stylesheet" href="/Public/static/css/amazeui.min.css?v=2">
	<link rel="stylesheet" href="/Public/static/css/app.css">
	<link rel="stylesheet" href="/Public/static/css/all.css">
	<title></title>
	<link rel="stylesheet" href="/Public/static/css/common.css">
	<link rel="stylesheet" href="/Public/static/css/iindex.css">
		<include file="Public/head" />
		<link type="text/css" rel="stylesheet" href="__PUBLIC__/Wchat/css/forget_pwd.css">
		<title>修改密码</title>
	</head>
	<body>
	    	<div class="comm_top_nav">
		<div class="am-g">
			<b>
				<div class="am-u-sm-2" onclick="javascript:window.location.href = '{:U('Index/more')}';"><i
						class="am-icon-angle-left am-icon-fw"></i></div>
				<div class="am-u-sm-8">修改密码</div>
				<div class="am-u-sm-2"></div>
			</b>
		</div>
	</div>
		<div class="res_con">
			<form action="{:U('Index/forgetpwd')}" method="post" id="findForm">
		        <ul>
		            <li>
<php>$user = getUserInfo();</php>
<empty name="user">
				<input type="number" placeholder="请输入11位数字" class="user">
<else />
				<input type="number" placeholder="请输入11位数字" class="user" value="{$user.telnum}" readonly="readonly" />
</empty>
		            </li>
		            <li class="yz">
		            	<input type="text" placeholder="请输入验证码" class="yzm">
		            	<button type="button">发送验证码</button>
		            </li>
		            <li class="fu_pwd">
		            	<input type="password" placeholder="请修改密码" class="pwd">
		            </li>
		        </ul>
		        <button class="abut1" id="findBtn" disabled="disabled" type="button">提交</button>
			</form>
            <div class="verify">
            	<p>
            		<img src="{:U('Index/verify')}" alt="看不清,换一张" />
            	</p>
            	<p>
            		<input type="number" value="" placeholder="输入验证码" />
            	</p>
            	<p>
            		<a class="btn" id="verifySendcode">确定</a>
            		<a class="btn btnred" id="verifyClose">取消</a>
            	</p>
            </div>
	    </div>
	    <div class="zhezhao"></div>
	   	<script type="text/javascript">
		//本脚本解决点击后跳出safari的问题
		(function(){	
			if ("standalone" in window.navigator && window.navigator.standalone) {
				var d, l = false;
				document.addEventListener("click", function(i) {
					d = i.target;
					while (d.nodeName !== "A" && d.nodeName !== "HTML") d = d.parentNode;
					//if ("href" in d && d.href.indexOf("http") !== -1 && (d.href.indexOf(document.location.host) !== -1 || l)) {
					if ("href" in d && d.href.indexOf("http") !== -1 ) {
						i.preventDefault();
						document.location.href = d.href
					}
				}, false)
			}
		}());
		
		</script>
	</body>
	<script>
	    	var resendTime = 0;
	    	var resendFun;
	    	$(function(){
	    		/*找回密码*/
	    		$(".res_con .yz button").on('click',function(){
	    			if(!cvphp.ismobile( $("#findForm .user").val() )){
	    				cvphp.msg({
	    					content: '手机号码不符合规范'
	    				});
	    				return false;
	    			}
	    			$(".verify input").val('');
	    			var imgUrl = "{:U('Index/verify',array('t','randTime'))}";
	    			imgUrl = imgUrl.replace(/randTime/,Date.parse(new Date()));
	    			$(".verify img").attr('src',imgUrl);
	    			$(".verify").show();
	    			$(".zhezhao").show();
	    			$(".verify input").focus();
	    		});
	    		$("#verifyClose").on('click',function(){
	    			$(".verify").hide();
	    			$(".zhezhao").hide();
	    		});
	    		$(".verify img").on('click',function(){
	    			var imgUrl = "{:U('Index/verify',array('t','randTime'))}";
	    			imgUrl = imgUrl.replace(/randTime/,Date.parse(new Date()));
	    			$(".verify img").attr('src',imgUrl);
	    		});
	    		$("#verifySendcode").on('click',function(){
	    			$(".verify").hide();
	    			$(".zhezhao").hide();
	    			var code = $(".verify input").val();
	    			if(code.length != 4){
						cvphp.msg({
	    					content: '请输入正确的图形验证码',
	    				});
	    				return ;
	    			}
	    			cvphp.post(
	    				"{:U('Sms/sendcode')}",
	    				{
	    					verify:code,
	    					user:$("#findForm .user").val(),
	    					type:'find'
	    				},
	    				function(data){
		    				if(data.status != 1){
		    					cvphp.msg({
		    						content: data.info,
		    					});
		    				}else{
		    					resendTime = 59;
		    					resendFun = setInterval(resend,1000);
				    			$(".verify").hide();
				    			$(".zhezhao").hide();
		    				}
	    				}
	    			);
	    		});
	    		$("#findForm .yzm").on('input',function(){
	    			var code = $(this).val();
	    			if(code.length == 4){
	    				$("#findBtn").removeAttr('disabled');
	    				$("#findBtn").removeClass('abut1');
	    				$("#findBtn").addClass('abut');
	    			}else{
	    				$("#findBtn").attr('disabled',"true");
	    				$("#findBtn").removeClass('abut');
	    				$("#findBtn").addClass('abut1');
	    			}
	    		});
	    		$("#findBtn").on('click',function(){
	    			if(!cvphp.ismobile( $("#findForm .user").val() )){
	    				cvphp.msg({
	    					content: '手机号码不符合规范'
	    				});
	    				return false;
	    			}
	    			if($("#findForm .yzm").val().length != 4){
	    				cvphp.msg({
	    					content: '请输入短信验证码'
	    				});
	    				return false;
	    			}
	    			if($("#findForm .pwd").val().length < 6 || $("#findForm .pwd").val().length > 18){
	    				cvphp.msg({
	    					content: '请输入6-18位登录密码'
	    				});
	    				return false;
	    			}
	    			cvphp.post(
	    				"{:U('Index/forgetpwd')}",
	    				{
	    					username:$("#findForm .user").val(),
	    					code:$("#findForm .yzm").val(),
	    					password:$("#findForm .pwd").val()
	    				},
	    				function(data){
		    				if(data.status != 1){
		    					cvphp.msg({
		    						content: data.info,
		    					});
		    				}else{
		    					cvphp.msg({
		    						content: '密码找回成功',
		    					});
		    					setTimeout(function(){window.location.href = data.url;},3000);
		    				}
	    				}
	    			);
	    		});
	    	});
	    	function resend(){
	    		if(resendTime == 1){
	    			$(".res_con .yz button").html('重新发送');
	    			clearInterval(resendFun);
	    			$(".res_con .yz button").removeAttr('disabled');
	    		}else{
	    			resendTime--;
	    			$(".res_con .yz button").html(resendTime + ' 秒重试');
	    			$(".res_con .yz button").attr('disabled',"true");
	    		}
	    	}
	</script>
</html>
